package network;

import core.Contact;
import java.io.IOException;
import java.net.Socket;
import protocol.ProtocolEngine;
import protocol.ProtocolEngineImpl;

/**
 * @author Peter Nikodem
 */
public class ClientConnectionImpl implements ClientConnection {

    private final ProtocolEngine protocol;
    private final ClientListener listener;
    private final ClientSender sender;
    private final Socket socket;

    public ClientConnectionImpl(Socket socket) {
        this.socket = socket;
        protocol = new ProtocolEngineImpl(this);
        sender = new ClientSender(socket, protocol);
        listener = new ClientListener(socket, protocol);
        listener.start();
        sender.start();
    }

    @Override
    public ClientSender getSender() {
        return sender;
    }
}
